package academic.concordia.bankofquebec.bean.authentication;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import academic.concordia.bankofquebec.entity.Client;

@Service
public class AuthenticationBean implements IAuthenticationBean {

	@Override
	public boolean AuthenticateUser(Client client) {
		// TODO This code will be used by Spring to verify the authentication
		Authentication authentication =  new UsernamePasswordAuthenticationToken(client.getIdNumber(), client.getPassword());
		SecurityContextHolder.getContext().setAuthentication(authentication);
		
		return true;
	}

}
